package app.server.project.core.globaldao;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.Objects;

@Repository
@Slf4j
public class GlobalDao extends ServiceImpl<GlobalMapper,GlobalEntity> {

    @Cacheable(key = "#id",cacheNames = "GlobalDao")
    public GlobalEntity getVal(String id){
        var val=this.getById(id);
        if (Objects.isNull(val)){
            val=GlobalEntity.of(id);
        }else {
            val.setSynDb(true);
        }
        return val;
    }
}
